#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#define max 85
#include<string.h>
char s[max];



int main()
{
	int T = 0;
	scanf("%d", &T);
	while (T--)
	{
		scanf("%s", s);
		int c = 0, h = 0, o = 0, n = 0;
		for (int i = 0; s[i]; i++)
		{
			switch (s[i])
			{

			case 'C':
				if (s[i + 1]  ==  '1' || s[i + 1] == '2'  || s[i + 1] == '3' || s[i + 1] == '4' || s[i + 1] == '5' || s[i + 1] == '6' || s[i + 1] == '7' || s[i + 1] == '8' || s[i + 1] == '9')
				{
					c += (s[i + 1]-'0');
					i++;
				}
				else
					c++;
				break;

			case'H':
				if (s[i + 1] == '1' || s[i + 1] == '2' || s[i + 1] == '3' || s[i + 1] == '4' || s[i + 1] == '5' || s[i + 1] == '6' || s[i + 1] == '7' || s[i + 1] == '8' || s[i + 1] == '9')
				{
					h += (s[i + 1] - '0');
					i++;
				}
				else
					h++;
				break;

			case'O':
				if (s[i + 1] == '1' || s[i + 1] == '2' || s[i + 1] == '3' || s[i + 1] == '4' || s[i + 1] == '5' || s[i + 1] == '6' || s[i + 1] == '7' || s[i + 1] == '8' || s[i + 1] == '9')
				{
					o += (s[i + 1] - '0'); 
					i++;
				}
				else
					o++;
				break;

			case'N':
				if (s[i + 1] == '1' || s[i + 1] == '2' || s[i + 1] == '3' || s[i + 1] == '4' || s[i + 1] == '5' || s[i + 1] == '6' || s[i + 1] == '7' || s[i + 1] == '8' || s[i + 1] == '9')
				{
					n += (s[i + 1] - '0');
					i++;
				}
				else
					n++;
				break;

			}

		}

		double sum = c * 12.01 + h * 1.008 + o * 16.00 + n * 14.01;
		printf("%.3lf", sum);
	}


	return 0;
}
